<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>合同详情</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<script src="${ctx}/rs/js/jquery.validate.min.js"></script>
<script src="${ctx}/rs/js/jquery.form.js" type="text/javascript"></script>
<script type="text/javascript" src="${ctx}/rs/js/imageBigAndKeyDownutils.js"></script>
<style>
.yangshi {
	position: relative;
	top: 7px;
}
.form-group{
margin-bottom:4px;
}
</style>
</head>
<body>
	<form id="form3" class="form-horizontal"
		action="${ctx}/contract/statussave.htm" method="post">
		<input type="hidden" class="form-control " id="type" name="type"
			value="${type}" />
		<input type="hidden" class="form-control " id="id" name="id"
			value="${id}" />
		
		<c:if test="${type eq 1 }">
			<div class="form-group">
				<label for="name" class="col-sm-3 control-label item ">合同编号：</label>
				<div class="col-sm-8 yangshi">${con.contractCode }</div>
			</div>
		</c:if>
		<c:if test="${type eq 2 }">
			<div class="form-group">
				<label for="name" class="col-sm-3 control-label item ">销售合同编号：</label>
				<div class="col-sm-8 yangshi">${con.sellCode}</div>
			</div>
			<div class="form-group">
				<label for="name" class="col-sm-3 control-label item ">采购合同编号：</label>
				<div class="col-sm-8 yangshi">${con.buyCode}</div>
			</div>
		</c:if>
		<c:if test="${type eq 2 }">
			<div class="form-group">
				<label for="name" class="col-sm-3 control-label item ">推广媒体：</label>
				<div class="col-sm-8 yangshi">${con.extendMedia }</div>
			</div>
		</c:if>
		<div class="form-group">
			<label for="name" class="col-sm-3 control-label item ">广告客户：</label>
			<div class="col-sm-8 yangshi ">${con.advName}</div>
		</div>
		<c:if test="${type eq 2 }">
			<div class="form-group">
				<label for="name" class="col-sm-3 control-label item ">广告产品：</label>
				<div class="col-sm-8 yangshi">${con.advProduct}</div>
			</div>
		</c:if>
		<div class="form-group">
			<label for="name" class="col-sm-3 control-label item ">签约总金额：</label>
			<div class="col-sm-8 yangshi  ">
				<c:if test="${type eq 1 }">￥${con.signSumMoney}</c:if>
				<c:if test="${type eq 2 }">￥${con.sumSignMoney}</c:if>
			</div>
		</div>
		<div class="form-group">
			<label for="name" class="col-sm-3 control-label item ">应付总金额：</label>
			<div class="col-sm-8 yangshi  ">
				<c:if test="${type eq 1 }">￥${con.copewithMoney }</c:if>
				<c:if test="${type eq 2 }">￥${con.copywithMoney }</c:if>
			</div>
		</div>
		
		<div class="form-group">
			<label for="name" class="col-sm-3 control-label item ">累计已付金额：</label>
			<div class="col-sm-8 yangshi  ">
				<c:if test="${type eq 1 }">￥${con.addupMoney }</c:if>
				<c:if test="${type eq 2 }">￥${con.addupMoney }</c:if>
			</div>
		</div>
		
		<div class="form-group">
			<label for="name" class="col-sm-3 control-label item ">未付金额：</label>
			<div class="col-sm-8 yangshi  ">
				<c:if test="${type eq 1 }">￥${con.nonPayMoney }</c:if>
				<c:if test="${type eq 2 }">￥${con.nonPayMoney }</c:if>
			</div>
		</div>
		<c:if test="${type eq 1 }">
		<div class="form-group">
			<label for="name" class="col-sm-3 control-label item ">媒体投放总金额：</label>
			<div class="col-sm-8 yangshi  ">￥${con.throwMoney}
			</div>
		</div>
		</c:if>
		
		<div class="form-group">
			<label for="name" class="col-sm-3 control-label item ">结算方式</label>
			<div class="col-sm-8 yangshi  ">
				<c:if test="${con.payWay==0}">预付</c:if>
				<c:if test="${con.payWay==1}">月付 </c:if>
			</div>
		</div>
		<div class="form-group">
			<label for="name" class="col-sm-3 control-label item ">签约日期：</label>
			<div class="col-sm-8 yangshi  ">${con.signTime }</div>
		</div>
		<c:if test="${type eq 1 }">
		<div class="form-group">
			<label for="name" class="col-sm-3 control-label item ">合同有效期：</label>
			<div class="col-sm-8 yangshi  ">
				${con.timeToTime}
			</div>
		</div>
		</c:if>
		<c:if test="${type eq 2 }">
		<div class="form-group">
			<label for="name" class="col-sm-3 control-label item ">投放期限：</label>
			<div class="col-sm-8 yangshi  ">
				${con.throwTime}
			</div>
		</div>
		</c:if>
		<div class="form-group">
			<label for="name" class="col-sm-3 control-label item ">合同状态：</label>
			<div class="col-sm-8 yangshi  ">
				<input type="hidden" id="contractStatusx" value="${con.contractStatus}" /> 
				<select class="srt-put1 mr10 widput1"
					id="contractStatus1" name="contractStatus">
					<option value="0"
						<c:if test="${con.contractStatus==0}">selected="selected"</c:if>>未启动</option>
					<option value="1"
						<c:if test="${con.contractStatus==1}">selected="selected"</c:if>>执行中</option>
					<option value="2"
						<c:if test="${con.contractStatus==2}">selected="selected"</c:if>>结束</option>
				</select>
			</div>
		</div>
		<c:if test="${type eq 1 }">
			<div class="form-group">
				<label for="name" class="col-sm-3 control-label item ">销售员：</label>
				<div class="col-sm-8 yangshi  ">${con.salesperson }</div>
			</div>
		</c:if>
		<c:if test="${type eq 2 }">
			<div class="form-group">
				<label for="name" class="col-sm-3 control-label item ">业务员：</label>
				<div class="col-sm-8 yangshi">${con.salesman }</div>
			</div>
		</c:if>
		<c:if test="${type eq 1 }">
			<div class="form-group">
				<label for="name" class="col-sm-3 control-label item ">合同情况：</label>
				<div class="col-sm-8 yangshi">
				<textarea rows="5" cols="50" disabled="true ">${con.remarks }</textarea>
				</div>
			</div>
		</c:if>
		<c:if test="${type eq 2 }">
            <div class="form-group">
                <label for="name" class="col-sm-3 control-label item ">合同扫描件：</label>
                <div class="col-sm-8 wid2" id="picall">
          
                 </div>
            </div>
        </c:if>
		<c:if test="${type eq 2 }">
			<div class="form-group">
				<label for="name" class="col-sm-3 control-label item ">备注：</label>
				<div class="col-sm-8 yangshi  ">${con.remarks }</div>
			</div>
		</c:if>
		
		<div class="form-group">
			<div class="col-sm-10 text-center pt15">
				<button type="button"
					class="btn btn-primary btn-lg srt-btn active mr30"
					onclick="valiSubmit1()">确定</button>
			</div>
		</div>

		<div class="form-group">
			<div class=" col-sm-10">
				<span id="error-text" style="color: #FF0000;"></span>
			</div>
		</div>
	</form>

	<script type="text/javascript" src="${ctx}/rs/js/bootstrapQ.min.js"></script>
 <script src="${ctx}/rs/js/messages_zh.min.js"></script>
 <!-- 引入所有joli的脚本 -->
   <%--  
     <script src="${ctx}/rs/js/jquery.formatDate.js"></script>
    <script src="${ctx}/rs/js/bootstrap-table.js"></script>
    <script src="${ctx}/rs/js/bootstrap-table-zh-CN.js"></script>
    <script src="${ctx}/rs/js/my97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="${ctx}/rs/js/session-out-error.js"></script> --%>
	<script type="text/javascript">
	$(document).ready(function(){
		coverFormatter('${conn}'); 
	});

    function imgBigNp(url) {
         qiao2.bs.dialog({
                url : '${ctx}/contract/imgBig.htm?url=' + url,
                id: 'imgBigNp',
                mstyle:'width:540px;',
                msg: '',
                title: '图片',
                foot: false
            });
    }
	function coverFormatter(value) {
		debugger
        var img="";
        if(value==""||value==null){
            var imgs=img+"暂无图片";
        }else{
        	var pics = JSON.parse(value);
            var imgs="";
            for(var a = 0; a<pics.length;a++){
               if(pics[a].buyUrl == null){
            	   var img = "暂无图片";
               }else{
            	   var img = "<a href='javascript:imgBigNp(\""+pics[a].buyUrl+"\")'><img width='30px' src='"+pics[a].buyUrl+"' height='40px' style='margin: 5px;border:1px #E3E3E3 solid;display:inline-block'/></a>";
               }
                imgs+=img;
            }
        }   
        $("#picall").html(imgs);    
    }
    //初始化验证 start
    var form3 = $('#form3');
    
   function valiSubmit1() {
    if (form3.valid()) {
    	var contractStatus1 = $("#contractStatus1").val();
    	var contractStatusx = $("#contractStatusx").val();
    	if (contractStatus1+0 < contractStatusx+0){
    		 bootstrapQ.msg({
                 msg : '合同状态只能往将来时方向修改！',
                 type : 'danger',
                 time : 2000
             });
    		return 
    	}else{
    		qiao2.bs.confirm('确定要更改合同信息？',function(){
                var options = {
                        dataType : "json",
                        data : {
                            data : $("#form3").serialize()
                        },
                        beforeSubmit : function() {
                            $(".unable").show();
                        },
                        success : function(result) {
                          
                            if (result) {
                                // 普通消息提示条
                                bootstrapQ.msg({
                                    msg : '操作成功，合同信息已更改！',
                                    type : 'success',
                                    time : 2000
                                });
                                //触发隐藏确认的按钮，引用回调方法关闭窗口并刷新列表
                             
                              setTimeout(adddd,1000) ;
                            } else {
                                bootstrapQ.msg({
                                    msg : '发布失败！',
                                    type : 'danger',
                                    time : 2000
                                });
                            }
                        },
                        error : function(result) {
                            if (!$('.unable').is(':hidden')) {
                                $(".unable").hide();
                            }
                            bootstrapQ.msg({
                                msg : '发布失败！',
                                type : 'danger',
                                time : 2000
                            });
                        }
                    };
            form3.ajaxSubmit(options);
    	},null);
        }
    }
    }
   
   
   function adddd(){
	   var type = $("#type").val()
	   if(type ==1 ){
	   window.location.href = "${ctx}/send.htm?page=contract/sellList";
       }else{
	   window.location.href = "${ctx}/send.htm?page=contract/buyList";
       }
   }
   
  
</script>
</body>
</html>